package com.原型模式.对象序列化实现深拷贝;

import com.原型模式.深拷贝.DeepCloneableTarget;

/**
 * @author Fang Ruichuan
 * @date 2022-09-22 13:28
 */

public class Client {
    public static void main(String[] args) {
        DeepProtoType p = new DeepProtoType();
        p.name = "宋江";
        p.deepCloneableTarget = new DeepCloneableTarget("大牛", "小牛的");

        // 方式二：完成深拷贝
        DeepProtoType p3 = (DeepProtoType) p.deepClone();
        System.out.println("p.name = " + p.name + "p.deepCloneableTarget = " + p.deepCloneableTarget.hashCode());
        System.out.println("p3.name = " + p3.name + "p3.deepCloneableTarget = " + p3.deepCloneableTarget.hashCode());
    }
}
